<template>
  <div class="tabs">
    <van-tabs color="#008fef" @click="onClick">
      <van-tab v-for="tab in tabs" :key="tab.id" :title="tab.cate_name" @click="handleClick(tab)"></van-tab>
    </van-tabs>
  </div>
</template>

<script>
import api from "../../api";

export default {
  data() {
    return {
      tabs: [
        {
          cate_name: "全部",
          id: ""
        }
      ]
    };
  },
  methods: {
    loadTabs() {
      api.product.cate(res => {
        res.forEach(element => {
          this.tabs.push(element);
        });
      });
    },
    onClick(index, title) {
      this.$emit("handleClick", index);
    }
  },

  mounted() {
    this.loadTabs();
  }
};
</script>

<style lang="less" scoped>
</style>